import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBWorkTaiModel/YBWorkTaiReMenModel.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBWorkTaiModule/YBFenXiangHuKePage/YBBaseProvider/YBBaseProvider.dart';
import 'YBHuKeSubPage/YBHuKeWodeWenZhangSubPage.dart';

class YBFenXiangWoDeWenZhangPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child:  Scaffold(
        appBar: AppBar(
          elevation: 0,
          title: Text(YBChineseText.workTaiMyDeWenZhangContent,style: YBTextStyle.TextStyle30313320Medium,),
        ),
        body: ChangeNotifierProvider(
            create:(context) => YBMyDeWenZhangProvider()..getWodeDataList(1),
            child: Consumer<YBMyDeWenZhangProvider>(
              builder: (context,MyDeWenZhangList,child){

                return SmartRefresher(
                  controller:MyDeWenZhangList.easyRefreshController,
                  onLoading: () async {
                    MyDeWenZhangList.loadData();
                  },
                  enablePullUp: true,
                  enablePullDown: true,
                  onRefresh: () async {
                    MyDeWenZhangList.refreshData();
                  },
                  child: CustomScrollView(
                    slivers: [
                      SliverList(
                        delegate: SliverChildBuilderDelegate((_,int index){
                          YBWorkTaiRemenModel workModel = MyDeWenZhangList.woDeModelList[index];
                          return Container(
                            color: YBColor.white,
                            child: Padding(
                              padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize10,bottom: YBTextStyle.adapterSize10),
                              child: YBHuKeWoDeWenZhangSubPage(MyModel: workModel,),
                            ),
                          );
                        },childCount: MyDeWenZhangList.woDeModelList.length),
                      ),
                    ],
                  ),
                );
              },
            ),
        ),
      ),
    );
  }
}
